package org.alis.rpc.common.serializer.alibaba;

import com.alibaba.fastjson.JSON;
import org.alis.rpc.common.serializer.Serializer;

/**
 *
 * 使用阿里巴巴的fastjson序列化 {url https://github.com/alibaba/fastjson}
 * @author lc
 * @version v1.0.0
 * @date 2020/8/20 16:26
 * @className JsonSerializer.class
 */
public class JsonSerializer implements Serializer {
    @Override
    public <T> byte[] serializer(T obj) {
        return JSON.toJSONString(obj).getBytes();
    }

    @Override
    public <T> T deserializer(byte[] bytes, Class<T> clazz) {
        return JSON.parseObject(bytes,clazz);
    }
}
